<?php
class View_Administration_Project_List extends View_Administration_Project
{
	public function buildContent()
	{
		$request	= CMF_Krypton_Core_Registry::getStatic( 'request' );
		$link		= $request->get( 'link' );
		$projects	= Logic_Project::getProjectList();
		$words		= $this->words['project']['listProjects'];
		$list		= array();
		foreach( $projects as $project )
		{
			$servers	= Logic_Project::getServersFromProject( $project['projectId'], 2 );
			foreach( $servers as $serverId => $serverData )
			{
				$title		= UI_HTML_Elements::Acronym( $serverData['title'], $serverData['description'] );
				$servers[$serverId]	= UI_HTML_Elements::Link( "?link=manageServers&serverId=".$serverId, $title );
			}
			$project['servers']	= implode( "<br/>", array_values( $servers ) );
			$project['link']	= $link;
			$project['project']	= Logic_Project::getProjectTitle( $project['projectId'] );
			$project['created']	= $project['created'] ? date( "d.m.Y H:i", $project['created'] ) : "";
			$project['modified']	= $project['modified'] ? date( "d.m.Y H:i", $project['modified'] ) : "";
			$list[]		= $this->loadTemplate( 'administration.project.item', $project );
		}
		$ui	= array(
			'words'		=> $words,
			'list'		=> implode( "\n", $list ),
			'buttonAdd'	=> $this->html->LinkButton(
				self::getUrl( array( 'action' => 'add' ) ),
				$words['buttonAdd'],
				'but add'
			),
		);
		return $this->loadTemplate( 'administration.project.list', $ui );
	}
}
?>